import os
import configparser
import sys
class Config(object):
    def __init__(self, config_file='config.ini'):
        self._path = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))  #--调试脚本路径
        # self._path =os.path.dirname(os.path.realpath(sys.executable))  #--打包时使用的路径
        self._path = os.path.join(self._path+"\\"+"confige", config_file)
        if not os.path.exists(self._path):
            raise FileNotFoundError("No such file: %s" % config_file)
        self._config = configparser.ConfigParser()
        # 读取配置文件，返回confi.ini全路径地址，列表形式
        self._config.read(self._path, encoding='utf-8-sig')
        # 读取配置文件，返回confi.ini全路径地址，列表形式
        self._configRaw = configparser.RawConfigParser()
        self._configRaw.read(self._path, encoding='utf-8-sig')

    def get(self, section, name):
        return self._config.get(section, name)

    def getRaw(self, section, name):
        return self._configRaw.get(section, name)


global_config = Config()

if __name__ == '__main__':
    print(global_config.getRaw('keywords', 'Imubegincontinuation'))